package com.bw.classfiy.mvvm.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bw.classfiy.R;
import com.bw.mvvm.network.load.LoadImage;
import com.youth.banner.adapter.BannerAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class ClassFiyBannerAdapter extends BannerAdapter<String, ClassFiyBannerAdapter.BannerViewHoldel> {

    public ClassFiyBannerAdapter(List<String> datas) {
        super(datas);
    }

    @Override
    public BannerViewHoldel onCreateHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.classfiy_banner_imager,parent,false);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        view.setLayoutParams(layoutParams);
        return new BannerViewHoldel(view);
    }

    @Override
    public void onBindView(BannerViewHoldel holder, String data, int position, int size) {
        LoadImage.loadMatchImg(data, holder.imageView);
    }

    public static class BannerViewHoldel extends RecyclerView.ViewHolder {
        ImageView imageView;
        public BannerViewHoldel(@NonNull @NotNull View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.classfiy_imgbanner_item);
        }
    }
}
